package com.mc.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
/**
 * @author fyp
 * 退出控制器
 */
@WebServlet("/exit.action")
public class ExitServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //得到会话
        HttpSession session=req.getSession();
        //让会话过期
        session.getMaxInactiveInterval();
        //会话过期的方法
        session.invalidate();
        //跳转到登录页面
        resp.sendRedirect("userlogin.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
